import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/11/10 19:40
 */

public class Solution {
    public List<Integer> findAnagrams(String s, String p) {

        List<Integer> list = new ArrayList<>();

        char[] charS = s.toCharArray();
        char[] charP = p.toCharArray();

        // 利用两个哈希表记录字符出现的次数
        int[] hash1 = new int[26];
        // 记录p中字符出现的次数
        for (char ch : charP) {
            hash1[ch - 'a']++;
        }

        // 滑动窗口中字符出现的次数
        int[] hash2 = new int[26];
        for (int left = 0, right = 0, count = 0; right < s.length(); right++) {
            // 当前进入窗口的字符
            char in = charS[right];
            if (++hash2[in - 'a'] <= hash1[in - 'a']) {
                count++;
            }

            if (right - left + 1 > p.length()) {
                // 离开窗口的字符
                char out = charS[left++];
                if (hash2[out - 'a']-- <= hash1[out - 'a']) {
                    count--;
                }
            }
            if (count == p.length()) {
                // 添加起始索引
                list.add(left);
            }
        }
        return list;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.nextLine();
            String p = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.findAnagrams(s, p));
        }
    }
}